package com.member.web.controller.shop;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.member.common.annotation.Log;
import com.member.common.core.controller.BaseController;
import com.member.common.core.domain.AjaxResult;
import com.member.common.core.page.TableDataInfo;
import com.member.common.enums.BusinessType;
import com.member.common.utils.poi.ExcelUtil;
import com.member.shop.domain.SysBizGoodsRank;
import com.member.shop.service.ISysBizGoodsRankService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
 * 【商品榜单】控制器
 *
 * @author lixinchen
 * @version 1.0
 * @date 2025-01-11
 **/
@RestController
@RequestMapping("/shop/goodsRank")
public class SysBizGoodsRankController extends BaseController {
    @Resource
    private ISysBizGoodsRankService sysBizGoodsRankService;

    /**
     * 查询商品榜单列表
     */
    @PreAuthorize("@ss.hasPermi('shop:goodsRank:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysBizGoodsRank sysBizGoodsRank) {
        startPage();
        List<SysBizGoodsRank> list = sysBizGoodsRankService.selectSysBizGoodsRankList(sysBizGoodsRank);
        return getDataTable(list);
    }

    /**
     * 导出商品榜单列表
     */
    @PreAuthorize("@ss.hasPermi('shop:goodsRank:export')")
    @Log(title = "商品榜单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysBizGoodsRank sysBizGoodsRank) {
        List<SysBizGoodsRank> list = sysBizGoodsRankService.selectSysBizGoodsRankList(sysBizGoodsRank);
        ExcelUtil<SysBizGoodsRank> util = new ExcelUtil<SysBizGoodsRank>(SysBizGoodsRank. class);
        util.exportExcel(response, list, "商品榜单数据");
    }

    /**
     * 获取商品榜单详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:goodsRank:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysBizGoodsRankService.selectSysBizGoodsRankById(id));
    }

    /**
     * 新增商品榜单
     */
    @PreAuthorize("@ss.hasPermi('shop:goodsRank:add')")
    @Log(title = "商品榜单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysBizGoodsRank sysBizGoodsRank) {
        return toAjax(sysBizGoodsRankService.insertSysBizGoodsRank(sysBizGoodsRank));
    }

    /**
     * 修改商品榜单
     */
    @PreAuthorize("@ss.hasPermi('shop:goodsRank:edit')")
    @Log(title = "商品榜单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysBizGoodsRank sysBizGoodsRank) {
        return toAjax(sysBizGoodsRankService.updateSysBizGoodsRank(sysBizGoodsRank));
    }

    /**
     * 删除商品榜单
     */
    @PreAuthorize("@ss.hasPermi('shop:goodsRank:remove')")
    @Log(title = "商品榜单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysBizGoodsRankService.deleteSysBizGoodsRankByIds(ids));
    }
}
